package main

func asteroidCollision(asteroids []int) []int {
	stack := []int{}
	for _, v := range asteroids {
		alive := true

		for alive && len(stack) > 0 && v < 0 && stack[len(stack)-1] > 0 {
			alive = stack[len(stack)-1] < -v
			if stack[len(stack)-1] <= -v {
				stack = stack[:len(stack)-1]
			}
		}
		if alive {
			stack = append(stack, v)
		}
	}
	return stack

}
